package com.shuangyulin.domain;

import java.io.File;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

import com.shuangyulin.dao.PidDAO;

public abstract class ConfigFile {
	private int fileType;	
	private File file;
	private String head[];
	String pidNameList[] = null;
		
	protected HashMap<Integer, Pid> pidList = new HashMap<Integer, Pid>();

	public abstract int readCfgFile();
	public abstract int writeCfgFile();
	
	public void DbWrite(Integer userId){
		PidDAO pidDAO = new PidDAO();
    	Iterator iter = pidList.entrySet().iterator();
    	
    	while (iter.hasNext()) {
    		Map.Entry entry = (Map.Entry) iter.next();
    		Object key = entry.getKey();
    		Pid val = (Pid)entry.getValue();
    		
    		try {
				pidDAO.AddPid(val, userId);
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
    		
    		/*
    		System.out.println(val.getPidIndex()
    				+ " "
    				+ val.getPidName()
    				+ " "
    				+ val.getSize()
    				+ " "
    				+ val.getPidType()
    				+ " "
    				+ val.getType()
    				+ " "
    				+ val.getAlarmStatus()
    				+ " "
    				+ val.getBypassStatus()
					+ " "
					+ val.getCompState()
					+ " "
					+ val.getOpvarType()
					+ " "
					+ val.getInhibited()
					+ " "
					+ val.getAck()
					+ " "
					+ val.getFlag()
					+ " "
					+ val.getChannelType()
					+ " "
					+ val.getDescription());
			*/
    	}
	}
	
	public void DbRead(){
		;
	}
}
